<template>
	<view>
		<!-- <input class="inputcss" type="number" placeholder="手机号码" @input="getPhone" /> -->
		<input class="inputcss" placeholder="请输入昵称" @input="getName" />
		<input class="inputcss" type="password" placeholder="请输入密码" @input="getPass" />
		<input class="inputcss" type="password" placeholder="请输入密码" @input="getPassRepeat" />
		<button class="buttoncss" @tap="Save">提交</button>
	</view>
</template>

<script>
	import api from "@/common/api.js";
	import {
		baseURL
	} from "@/common/http.js";
	export default {
		data() {
			return {
				phone: '',
				name: '',
				pass: '',
				passR: '',
				id: ''
			};
		},
		methods: {
			getName(e) {
				this.name = e.detail.value
			},
			getPass(e) {
				this.pass = e.detail.value
			},
			getPassRepeat(e) {
				this.passR = e.detail.value
			},
			Save() {
				if (this.name == '') {
					uni.showToast({
						title: '请先输入用户名',
						duration: 1500,
						icon: 'none'
					})
				} else if (this.pass == '') {
					uni.showToast({
						title: '请输入密码',
						duration: 1500,
						icon: 'none'
					})
				} else {
					if(this.passR !== this.pass) {
						uni.showToast({
							title: '两次输入的密码不一致',
							duration: 1500,
							icon: 'none'
						})
					} else {
						api.look({
							call: this.phone,
							name: this.name,
							password: this.pass,
							api: 'namezhu'
						}).then(res => {
							if (res.code == 200) {
								this.id = res.date[0].id
								uni.navigateTo({
									url: '../registerThree/registerThree?cell=' + this.phone + '&pass=' + this.pass + '&name=' + this.name + '&id=' + this.id
								})
							}
						}).catch(err => {
							console.log(err)
						})
					}
				}
			}
		},
		onShareAppMessage(options) {
			let shareObj = {
				success: (res) => {
					if (res.errMsg == 'shareAppMessage:ok') {
						uni.showToast({
							title: '分享成功',
							icon: 'success',
							duration: 1500
						})
					}
				},
				fail: () => {
					if (res.errMsg == 'shareAppMessage:fail cancel') {
						uni.showToast({
							title: '取消分享',
							icon: 'none',
							duration: 2000
						})
					} else if (res.errMsg == 'shareAppMessage:fail') {
						// 转发失败，其中 detail message 为详细失败信息
					}
				},
				complete: () => {
					// 转发结束之后的回调（转发成不成功都会执行）
				}
			}
		},
		onLoad(options) {
			this.phone = options.cell
		}
	}
</script>

<style lang="scss">
	.inputcss {
		width: 690rpx;
		height: 100rpx;
		line-height: 100rpx;
		padding-left: 20rpx;
		box-sizing: border-box;
		margin: 40rpx auto 0;
		border-bottom: 1rpx solid #999;
	}

	.buttoncss {
		width: 690rpx;
		height: 100rpx;
		line-height: 100rpx;
		color: #fff;
		font-size: 40rpx;
		text-align: center;
		border-radius: 50rpx;
		background-color: #209FFC;
		margin: 100rpx auto 0;
	}
</style>
